// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
	env: cloud.DYNAMIC_CURRENT_ENV
})

const db = cloud.database()
const _ = db.command

// 云函数入口函数
exports.main = async (event, context) => {
  const searchContent = event.searchContent
  
  return await db.collection('lost_and_found_infos').where(_.or([{
  		is_found: false,
  		student_name: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  
  	},
  	{
  		is_found: false,
  		type: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  	},
  	{
  		is_found: false,
  		item_name: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  	},
  	{
  		is_found: false,
  		location: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  	},
  	{
  		is_found: false,
  		bank_card_name: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  	},
  	{
  		is_found: false,
  		bank_card_No: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  	},
  	{
  		is_found: false,
  		movie_card_No: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  	},
  	{
  		is_found: false,
  		description: db.RegExp({
  			regexp: searchContent,
  			options: 'i'
  		}),
  	},
  ])).count()
}